package top.loonglove.bean;

import top.loonglove.status.ElementType;

import java.util.Objects;

/**
 * @author 向贵龙
 * @date 2021/7/12
 * 单行标签
 */
public class SingleElement extends AbstractElement {
    private String prefix;

    public SingleElement( String prefix,String value) {
        super(value);
        this.prefix = prefix;
    }

    public SingleElement() {
        super();
    }

    public SingleElement(String prefix, String value, ElementType type) {
        super(value, type);
        this.prefix = prefix;
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        SingleElement that = (SingleElement) o;
        return Objects.equals(prefix, that.prefix);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), prefix);
    }

    @Override
    public String toString() {
        return String.format("%s %s",prefix,value);
    }
}
